package org.toolbook.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
/**
 * 修改词条的验证器
 * @author meigang
 * @date 2015-07-02 13:31
 *
 */
public class UpdateNewWordValidator extends Validator{

	@Override
	protected void validate(Controller c) {
		validateString("title", 1, 24, "title_info", "词条名长度[1-24]");
		validateString("note", 1, 120, "note_info", "词条摘要长度[1-120]");
		validateString("belong", 1, 40, "belong_info", "词条所属领域长度[1-40]");
		validateRequired("content", "content_info", "词条内容不能为空");
		
		String filePath = c.getPara("lookPhotoFilePath");
		if(filePath == null || filePath.equals("")){
			addError("lookPhotoFilePath_info", "缩览图未上传");
		}
	}

	@Override
	protected void handleError(Controller c) {
		// TODO Auto-generated method stub
		c.keepPara("title");
		c.keepPara("note");
		c.keepPara("content");
		c.keepPara("belong");
		c.keepPara("lookPhotoFilePath");
		c.render("/WEB-INF/pages/fc/newword/update.jsp");
	}

}
